package com.qt.thread.scxf;

/**
 * @Author zsf
 * @Date 2023/10/3 14:51
 * @Version 1.0
 */
public class Foodie extends  Thread{

    public Foodie() {
    }

    public Foodie(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (true){
            synchronized (Desk.lock) {
                if(Desk.foodCount == 0 ){
                    break;
                }else {
                    if(Desk.flag){
                        Desk.foodCount--;
                        Desk.flag = false;
                        System.out.println("憨货正在吃饭还能吃" + Desk.foodCount + "份");
                        Desk.lock.notifyAll();
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                    }else {

                    }
                }
            }

        }
    }
}
